package base.day26.tcp;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ReceptionDemo3 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss=new ServerSocket(20000);
        ThreadPoolExecutor pool=new ThreadPoolExecutor(
                3,//核心线程数量
                10,  //线程池的总数量
                60,//临时线程空闲时间
                TimeUnit.SECONDS,//临时线程空闲时间单位
                new ArrayBlockingQueue<>(5),//阻塞队列
                Executors.defaultThreadFactory(),//创建线程的方式
                new ThreadPoolExecutor.AbortPolicy()
        );
        while (true){
            Socket accept = ss.accept();
            ThreadDome1 td=new ThreadDome1(accept);
            //new Thread(td).start();
            pool.submit(td);
        }

    }

}
